package com.zkr.controller;


import com.zkr.pojo.User;
import com.zkr.service.UserService;
import com.zkr.vo.SysResult;
import com.zkr.vo.UserResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 *
 * 功能描述:
 * @author:mayue
 * @date: 2018/8/29 下午 6:45
 *
 */
@RestController
@RequestMapping("/user")
public class UserController {
	@Autowired
	private UserService userService;
	
	@RequestMapping("/find")
	public UserResult find(){
		return userService.find();
	}



/**
 *
 * 功能描述:
 * @author:mayue
 * @date: 2018/8/29 下午 6:45
 * @param: [id]
 * @return: com.zkr.pojo.User
 * @throws:
 *
 */
    @RequestMapping("/findById/{id}")
    @ApiOperation(value="获取用户详细信息", notes="根据url的id来获取用户详细信息")
	public User findById(@PathVariable Integer id){

		return userService.findById(id);
	}
	@RequestMapping("/saveUser")
	public SysResult saveUser(@Validated User user){
    	System.out.println(user);
		userService.saveUser(user);
    	return SysResult.oK();
	}

}
